/*
 * @Author: your name
 * @Date: 2021-10-17 22:05:00
 * @LastEditTime: 2021-10-18 18:58:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\背包\多重背包\P2347 砝码称重\main.cpp
 */
#include<iostream>
#include<algorithm>
using namespace std;

//砝码单位
int w[7] = {0,1,2,3,5,10,20};
//f[i] 对于i重量 获得的最大方案数
int f[1010];
//f[i][j] 前i个砝码 对于j重量 获得的最大方案数ff
int ff[100][1010];
//二进制处理后得到的砝码
int ww[500];

int main(){
    int num = 1;
    int sumw = 0;
    for(int i=1; i<=6; i++){
        //第i种砝码数目
        int n;
        cin >> n;
        sumw += n*w[i];
        for(int j=1; j<=n; j<<=1){
            ww[num++] = w[i]*j;
            n -= j;
        }
        if(n){
            ww[num++] = w[i]*n;
        }
    }

    // for(int i=1; i<num; i++){
    //     cout << ww[i] << endl;
    // }
    // cout << sumw << endl;
    // cout << "----------------" << endl;

    f[0] = 1;
    for(int i=1; i<num; i++){
        for(int j=0; j<=sumw; j++){
            if(j < ww[i]){
                ff[i][j] = ff[i-1][j];
            }else if(j == ww[i]){
                //前i个砝码可以凑出j质量
                ff[i][j] = 1;
            }else{
                //j > w f[i][j] 跟随 f[i-1][j-ww[i]]的属性
                ff[i][j] = ff[i-1][j-ww[i]];
            }
        }
        // for(int j=0; j<=sumw; j++){
        //     cout << "j=" << j << "   " << ff[i][j] << endl;
        // }
        // cout << endl;
        for(int j=sumw; j>=ww[i]; j--){
            f[j] = f[j-ww[i]];
        }
        // for(int j=0; j<=sumw; j++){
        //     cout << "j=" << j << "   " << f[j] << endl;
        // }
        // cout << endl;
    }
    // cout << ff[num-1][sumw] << endl;
    int total = 0;
    int totalf = 0;
    for(int i=1; i<=sumw; i++){
        total += ff[num-1][i];
        totalf += f[i];
    }
    
    // cout << "Total=" << total << endl;
    cout << "Total=" << totalf << endl;
    return 0;
}
